package cn.lingyangwl.agile.misc.statistic.model;

import cn.lingyangwl.agile.misc.statistic.model.entity.*;
import cn.lingyangwl.agile.model.constants.RequestCons.*;
import cn.lingyangwl.agile.model.enums.*;
import cn.lingyangwl.agile.model.module.mq.*;
import cn.lingyangwl.framework.core.utils.servlet.*;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;

/**
 * @author shenguangyang
 */
@Getter
@Setter
public abstract class StatisticBaseReq extends BaseMqPayload {
    protected LocalDateTime dateTime = LocalDateTime.now();

    /**
     * 终端类型
     * @see cn.lingyangwl.agile.model.enums.TerminalEnum
     */
    protected String terminal;

    /**
     * 一般作为消息队列名称和路由key名称
     */
    public abstract String getName();

    public abstract Class<? extends StatBasePO> getEntityClass();

    public StatisticBaseReq() {
        this.terminal = ServletUtils.getRequest().map(e -> e.getHeader(Headers.TERMINAL)).orElse(TerminalEnum.DEFAULT.getTerminal());
    }
}
